
/**
 * Author(s): xuming.Wong <xuming.Wong@gmail.com>
 */
#include "MeshInfo.h"

namespace PQEngine
{
	MeshInfo::MeshInfo()
	{
		//_meshSerializer = new Ogre::MeshSerializer();
		//_skeletonSerializer = new Ogre::SkeletonSerializer();
	}
	MeshInfo::~MeshInfo()
	{
		//delete _meshSerializer;
		//delete _skeletonSerializer;
	}

	void MeshInfo::init(Ogre::Entity* entity)
	{
		if(!entity){
			return;
		}

		//GDataGenerator* generator=new GDataGenerator(GDATA_MESH_INFO);
		
		Ogre::AnimationStateSet *anims=_selectedEntity->getAllAnimationStates();
		std::vector<std::string> list;
		if(anims){
			Ogre::AnimationStateIterator iter=anims->getAnimationStateIterator();
			while(iter.hasMoreElements()){
				Ogre::AnimationStateMap::mapped_type i=iter.getNext();
				list.push_back(i->getAnimationName());
			}
		}

		int size=list.size();
		//generator->addIntParam(size);
		for(int i=0;i<size;i++){
			//generator->addStringParam(list[i]);
		}

		//GDatagram* datagram=generator->genDatagram();
		//return datagram;
	}

	void MeshInfo::buildMaterialTree()
	{
		Ogre::MeshPtr meshPtr=_selectedEntity->getMesh();
		unsigned short cnt=meshPtr->getNumSubMeshes();
		for(unsigned short i=0;i<cnt;i++){
			Ogre::SubMesh* sm=meshPtr->getSubMesh(i);
			Ogre::MaterialPtr mat=Ogre::MaterialManager::getSingleton().getByName(sm->getMaterialName());
			if(!mat.isNull()){
			}
		}
	}

	void MeshInfo::buildAnimations()
	{
		Ogre::AnimationStateSet *anims=_selectedEntity->getAllAnimationStates();
		if(anims){
			Ogre::AnimationStateIterator iter=anims->getAnimationStateIterator();
			while(iter.hasMoreElements()){
				Ogre::AnimationStateMap::mapped_type i=iter.getNext();
				//i->getAnimationName();
			}
		}
	}
}
